//
//  ViewController.m
//  LYReader
//
//  Created by linya on 2016/11/23.
//  Copyright © 2016年 linya. All rights reserved.
//

#import "ViewController.h"
#import "TFHpple.h"

#import "GDataXMLNode.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *str = [NSString stringWithFormat:@"http://wanmeishijiexiaoshuo.org/book/1992.html"];
    NSURL *url = [NSURL URLWithString:str];
    NSURLRequest *requsst = [NSURLRequest requestWithURL:url];
    UITextView *tv = [[UITextView alloc] initWithFrame:self.view.frame];
    [self.view addSubview:tv];
    
    
    
//    [NSURLConnection sendAsynchronousRequest:requsst queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {
////        NSLog(@"--->>>data is %@",data);
////        NSLog(@"--->>>connectionError is %@",connectionError);
////        NSLog(@"--->>>response is %@",response);
////        TFHpple *xpathParser = [[TFHpple alloc] initWithHTMLData:data];
////
////        NSArray *elements  = [xpathParser searchWithXPathQuery:@"//body"];
////        for (TFHppleElement *element in elements) {
//////            NSLog(@"%@", element);
////            NSArray *nodeChildArray = element.children;
////            
////            for (TFHppleElement *element in nodeChildArray) {
////                if ([element.tagName isEqualToString:@"div"]) {
//////                    NSLog(@"<<<<<<-----tagName is %@----->>>>>%@",element.tagName,element.content);
////                    NSLog(@"%@", element);
////                }
////            }
////        }
//        GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:data encoding:NSUTF8StringEncoding  error:NULL];
//        if (doc) {
////            NSArray *employees = [doc nodesForXPath:@"//head" error:NULL];
////            for (GDataXMLElement *employe in employees) {
////                NSLog(@"GDataXMLElement is %@",employe);
////            }
//            GDataXMLElement *employe = [doc rootElement];
//            NSLog(@"rootElement is %@",employe.XMLString);
//            tv.text =employe.XMLString;
//        }
//
//    }];
      // Do any additional setup after loading the view, typically from a nib.
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
